﻿
namespace Admin.NET.Application.Service;

/// <summary>
/// 血液品种
/// </summary>
public class BasXueYePinZhongService : BaseService<BasXueYePinZhong>
{
    public BasXueYePinZhongService(IServiceScopeFactory scopeFactory) : base(scopeFactory)
    {
    }

    /// <summary>
    /// 获取列表
    /// </summary>
    public async Task<SqlSugarPagedList<BasXueYePinZhongOutput>> Page(BaseKeywordPageInput input)
    {
        return await Queryable
           .WhereIF(input.Keyword.HasValue(), it => it.mingCheng.Contains(input.Keyword))
           .Select<BasXueYePinZhongOutput>()
           .OrderBy(it => new { it.orderNo })
           .ToPagedListAsync(input.Page, input.PageSize);
    }

    /// <summary>
    /// 用于缓存
    /// </summary>
    public List<BasXueYePinZhongAllOutput> All()
    {
        return _rep.Queryable
            .Select<BasXueYePinZhongAllOutput>()
            .OrderBy(it => new { it.orderNo })
            .ToList();
    }

    /// <summary>
    /// 通过Id获取
    /// </summary>
    public BasXueYePinZhongOutput Get(long id)
    {
        return GetById<BasXueYePinZhongOutput>(id);
    }

    /// <summary>
    /// 新增成功后返回主键
    /// </summary>
    public long Add(BasXueYePinZhongInput input)
    {
        return AddWithInput(input);
    }

    /// <summary>
    /// 更新成功后返回true
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    public bool Update(BasXueYePinZhongInput input)
    {
        return UpdateWithInput(input);
    }
}
